package demo

import (
	"fmt"
	"gitee.com/851537/gmodel"
	jsoniter "github.com/json-iterator/go"
)

type Printer struct {
	gmodel.BaseDbRedisSet
	Id int64 `json:"id" gorm:"primaryKey"`

	ShopId int64 `json:"shop_id"`

	Name string `json:"name" gorm:"size(255)"`

	//decimal返回的是[]byte类型
	Amt gmodel.Precision2 `json:"amt" gorm:"type:decimal(11,2)"`

	//precision返回的是float64类型
	//Amt gmodel.Amount `json:"amt" gorm:"precision:11,2"`

	CreatedAt int64 `json:"create_at"`
	UpdatedAt int64 `json:"update_at"`
}

func (this *Printer) TableName() string {
	return DbPrefix + "printer"
	//return this.BaseDb.TableName("user")
}

func (this *Printer) GetId() int64 {
	return this.Id
}

func (this *Printer) SetRedisModel(_type int8) gmodel.IRedisSet {
	m := &gmodel.BaseRedisSetModel{}
	m.Name = fmt.Sprintf("Printer.%d", this.Id)
	m.Value, _ = jsoniter.MarshalToString(this)
	m.Expire = 3600 * 12 * 7
	m.DbWhere = []interface{}{"id", this.Id}
	m.DbOrder = ""
	this.BaseDbRedisSet.Init(m)
	return this
}
